package pers.cj.pdos.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pers.cj.pdos.entity.BorrowInBackGoods;
import pers.cj.pdos.entity.MoneyWater;
import pers.cj.pdos.mapper.BorrowInBackGoodsMapper;
import pers.cj.pdos.mapper.MoneyWaterMapper;
import pers.cj.pdos.service.IBorrowInBackGoodsService;
import pers.cj.pdos.service.IMoneyWaterService;
import pers.cj.pdos.utils.Utils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenj
 * @since 2020-03-25
 */
@Service
public class MoneyWaterServiceImpl extends ServiceImpl<MoneyWaterMapper, MoneyWater> implements IMoneyWaterService {
    @Autowired
    MoneyWaterMapper moneyWaterMapper;

    @Override
    public List<Map> listVo(String companyId,
                            Integer page,
                            Integer limit,
                            Boolean close,
                            String search,
                            String no,
                            String unitName,
                            String userStoreId,
                            String userId,
                            String settAccountId,
                            Integer type,
                            Integer typeProject,
                            Date date1,
                            Date date2,
                            String storeId) {
        return moneyWaterMapper.listVo(companyId,
                Utils.genPage(page,limit),
                limit,
                close,
                search,
                no,
                unitName,
                userStoreId,
                userId,
                settAccountId,
                type,
                typeProject,
                date1,
                date2,
                storeId);
    }

    @Override
    public long count(String companyId,
                      Boolean close,
                      String search,
                      String no,
                      String unitName,
                      String userStoreId,
                      String userId,
                      String settAccountId,
                      Integer type,
                      Integer typeProject,
                      Date date1,
                      Date date2,
                      String storeId) {
        return moneyWaterMapper.count(companyId,
                close,
                search,
                no,
                unitName,
                userStoreId,
                userId,
                settAccountId,
                type,
                typeProject,
                date1,
                date2,
                storeId);
    }

    @Override
    public BigDecimal getTotalAmount(String companyId, String storeId, String userId, Date date1, Date date2) {
        return moneyWaterMapper.getTotalAmount(companyId,storeId,null, userId, date1, date2);
    }

    @Override
    public List<Map> listTotalGroupByDate(String companyId, String storeId, String userId, Date date1, Date date2) {
        return moneyWaterMapper.listTotalGroupByDate(companyId,storeId,null, userId, date1, date2);
    }
}
